// File Name: 
// Author:  Yao@HunterSun Electronics Co. Ltd
// Date: 2013-04-03


#ifndef C8051F38X_CLOCK_H
#define C8051F38X_CLOCK_H

//C8051F38x has 3 clock source,include a programmable internal high-frequency oscillator, a programmable internal low-frequency oscillator and an external oscillator.

#define C8051F38X_INTERNAL_HIGH_FREQ_OSC  0x01             // internal high-frequency oscillator
#define C8051F38X_INTERNAL_LOW_FREQ_OSC   0x02             // internal low-frequency oscillator
#define C8051F38X_EXTERNAL_OSC            0x03             // external oscillator


//-----------------------------configure SYSCLK------------------------------------ 

//according to hardware to select
#define C8051F38X_SYSCLK_SOURCE C8051F38X_INTERNAL_HIGH_FREQ_OSC      //config SYSCLK source


#if (C8051F38X_SYSCLK_SOURCE==C8051F38X_INTERNAL_HIGH_FREQ_OSC)    //internal high-frequency oscillator
	#define FREQ_1M5   0x15            //1.5MHz
	#define FREQ_3M    0x30            //3MHz
	#define FREQ_6M    0x60            //6MHz
	#define FREQ_12M   0x12            //12MHz
	#define FREQ_24M   0x24            //24MHz
	#define FREQ_48M   0x48            //48MHz
  
	#define C8051F38X_SYSCLK       FREQ_48M             //config SYSCLK    
  //add the others clock source
#endif


//-------------------------configure USBCLK---------------------------------------
#define C8051F38X_USBCLK_SOURCE C8051F38X_INTERNAL_HIGH_FREQ_OSC

//USBCLK 
#if (C8051F38X_USBCLK_SOURCE==C8051F38X_INTERNAL_HIGH_FREQ_OSC)
	#define USBCLK_48M  0x00 
 	#define USBCLK_6M   0x01
	
	#define C8051F38X_USBCLK    USBCLK_48M
#endif



extern void SysClkInit(void);

#endif  /*C8051F38X_CLOCK_H*/


/*--------------------------------End Of File--------------------------------*/
